home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / BARNET / ARMTEX / SOURCES1 / !TeX / texmf / source / armTeX / lib / h / texmfmem < prev    next >
Encoding:
Text File  |  1998-03-15  |  3.5 KB  |  135 lines

  1. /* texmfmem.h: the memory_word type, which is too hard to translate
  2.    automatically from Pascal.  We have to make sure the byte-swapping
  3.    that the (un)dumping routines do suffices to put things in the right
  4.    place in memory.
  5.  
  6.    A memory_word can be broken up into a `twohalves' or a
  7.    `fourquarters', and a `twohalves' can be further broken up.  Here is
  8.    a picture.  ..._M = most significant byte, ..._L = least significant
  9.    byte.
  10.    
  11.    If BigEndian:
  12.    twohalves.v:  RH_M  RH_L  LH_M  LH_L
  13.    twohalves.u:  JNK1  JNK2    B0    B1
  14.    fourquarters:   B0    B1    B2    B3
  15.    
  16.    If LittleEndian:
  17.    twohalves.v:  LH_L  LH_M  RH_L  RH_M
  18.    twohalves.u:    B1    B0  JNK1  JNK2
  19.    fourquarters:   B3    B2    B1    B0
  20.    
  21.    The halfword fields are four bytes if we are building a TeX or MF;
  22.    this leads to further complications:
  23.    
  24.    BigEndian:
  25.    twohalves.v:  RH_MM RH_ML RH_LM RH_LL LH_MM LH_ML LH_LM LH_LL
  26.    twohalves.u:  ---------JUNK----------  B0    B1
  27.    fourquarters:   B0    B1    B2    B3
  28.  
  29.    LittleEndian:
  30.    twohalves.v:  LH_LL LH_LM LH_ML LH_MM RH_LL RH_LM RH_ML RH_MM
  31.    twohalves.u:  junkx junky  B1    B0
  32.    fourquarters: ---------JUNK----------  B3    B2    B1    B0
  33.  
  34.    I guess TeX and Metafont never refer to the B1 and B0 in the
  35.    fourquarters structure as the B1 and B0 in the twohalves.u structure.
  36.    
  37.    This file can't be part of texmf.h, because texmf.h gets included by
  38.    {tex,mf}d.h before the `halfword' etc. types are defined.  So we
  39.    include it from the change file instead.
  40. */
  41.  
  42. /* Under RISC OS there's a big performance panalty to using shorts. Therefore halfword is defined as int, even with -DSMALLTeX */
  43. #if defined(SMALLTeX) || defined(SMALLMF)
  44. typedef unsigned short packed_halfword;
  45. #else /* not SMALLTeX */
  46. typedef halfword packed_halfword;
  47. #endif
  48.  
  49. typedef union
  50. {
  51.   struct
  52.   {
  53. #ifdef WORDS_BIGENDIAN
  54.     packed_halfword RH, LH;
  55. #else
  56.     packed_halfword LH, RH;
  57. #endif
  58.   } v;
  59.  
  60.   struct
  61.   { /* Make B0,B1 overlap the most significant bytes of LH.  */
  62. #ifdef WORDS_BIGENDIAN
  63.     packed_halfword junk;
  64.     quarterword B0, B1;
  65. #else /* not WORDS_BIGENDIAN */
  66.   /* If 32-bit TeX/MF, have to have an extra two bytes of junk.  
  67.      I would like to break this line, but I'm afraid that some
  68.      preprocessors don't properly handle backslash-newline in # commands.  */
  69. #if (defined (TeX) && !defined (SMALLTeX)) || !defined (TeX) && !defined (SMALLMF)
  70.     quarterword junkx, junky;
  71. #endif /* big TeX or big MF */
  72.     quarterword B1, B0;
  73. #endif /* not WORDS_BIGENDIAN */
  74.   } u;
  75. } twohalves;
  76.  
  77. typedef struct
  78. {
  79.   struct
  80.   {
  81. #ifdef WORDS_BIGENDIAN
  82.     quarterword B0, B1, B2, B3;
  83. #else
  84.     quarterword B3, B2, B1, B0;
  85. #endif
  86.   } u;
  87. } fourquarters;
  88.  
  89.  
  90. typedef union
  91. {
  92. #ifdef TeX
  93.   glueratio gr;
  94.   twohalves hh;
  95. #else
  96.   twohalves hhfield;
  97. #endif
  98. #ifdef WORDS_BIGENDIAN
  99.   integer cint;
  100.   fourquarters qqqq;
  101. #else /* not WORDS_BIGENDIAN */
  102.   struct
  103.   {
  104. #if defined (TeX) && !defined (SMALLTeX) || !defined (TeX) && !defined (SMALLMF)
  105.     packed_halfword junk;
  106. #endif /* big TeX or big MF */
  107.     integer CINT;
  108.   } u;
  109.  
  110.   struct
  111.   {
  112. #if defined (TeX) && !defined (SMALLTeX) || !defined (TeX) && !defined (SMALLMF)
  113.     packed_halfword junk;
  114. #endif /* big TeX or big MF */
  115.     fourquarters QQQQ;
  116.   } v;
  117. #endif /* not WORDS_BIGENDIAN */
  118. } memoryword;
  119.  
  120.  
  121. /* To keep the original structure accesses working, we must go through
  122.    the extra names C forced us to introduce.  */
  123. #define    b0 u.B0
  124. #define    b1 u.B1
  125. #define    b2 u.B2
  126. #define    b3 u.B3
  127.  
  128. #define rh v.RH
  129. #define lhfield    v.LH
  130.  
  131. #ifndef WORDS_BIGENDIAN
  132. #define cint u.CINT
  133. #define qqqq v.QQQQ
  134. #endif
  135.